package prassein.rsm.common.utils;

import java.util.Calendar;

import prassein.rsm.dto.PermLevelDto;

public class Utility {
	public static int GetDate() {
		Calendar cal = Calendar.getInstance();
		
		return cal.get(Calendar.HOUR_OF_DAY)
				+ cal.get(Calendar.DAY_OF_MONTH) * 100
				+ (cal.get(Calendar.MONTH) + 1) * 100 * 100
				+ cal.get(Calendar.YEAR) * 100 * 100 * 100;
	}
	
	public static String GetPermString(long permInt) {
		StringBuilder result = new StringBuilder();
		
		//if (permInt % 10 == 1) {result.append("新建简历; ");}
		if ((permInt % 100) / 10 == 1) {result.append("新建简历; ");}
		if ((permInt % 1000) / 100 == 1) {result.append("编辑简历; ");}
		if ((permInt % 10000) /1000 == 1) {result.append("管理简历; ");}
		if ((permInt % 100000) / 10000 == 1) {result.append("超级搜索; ");}
		if ((permInt % 1000000) / 100000 == 1) {result.append("新建用户; ");}
		if ((permInt % 10000000) / 1000000 == 1) {result.append("编辑用户; ");}
		if ((permInt % 100000000) / 10000000 == 1) {result.append("用户管理; ");}
		if ((permInt % 1000000000) / 100000000 == 1) {result.append("下载Excel; ");}
		if ((permInt % 10000000000L) / 1000000000 == 1) {result.append("系统管理; ");}
		
		return result.toString();
	}
	
	public static PermLevelDto GetPermLevelDto(long permInt) {
		PermLevelDto dto = new PermLevelDto();
		
		if (permInt % 10 == 1) {dto.setCreateResume("true");}
		if ((permInt % 100) / 10 == 1) {dto.setCreateResume("true");}
		if ((permInt % 1000) / 100 == 1) {dto.setEditResume("true");}
		if ((permInt % 10000) /1000 == 1) {dto.setDeleteResume("true");}
		if ((permInt % 100000) / 10000 == 1) {dto.setSurperSearch("true");}
		if ((permInt % 1000000) / 100000 == 1) {dto.setCreateUser("true");}
		if ((permInt % 10000000) / 1000000 == 1) {dto.setEditUser("true");}
		if ((permInt % 100000000) / 10000000 == 1) {dto.setDeleteUser("true");}
		if ((permInt % 1000000000) / 100000000 == 1) {dto.setCreateXls("true");}
		if ((permInt % 10000000000L) / 1000000000 == 1) {dto.setSysManager("true");}
		
		return dto;
	}
}
